﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
using System.Data;

public partial class CourseListManagement_UpdateCourseList : AdminUserBase
{
    CourseListModule clm = new CourseListModule();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            showCouerlist();
            hfId.Value = Request.QueryString["id"];

        }
    }

    //确认修改
    protected void btnReg_Click(object sender, EventArgs e)
    {
        V_courselist clist = new V_courselist();
        clist.ID =Convert.ToInt32(Request.QueryString["id"]);
        clist.TrainClassId = Convert.ToInt32(this.hidTraninClass.Value);
        clist.SchoolID = this.CurrentUser.SchoolID;
        clist.RoomID = Convert.ToInt32(this.hidCoursewareIdList.Value);
        clist.teacherID = Convert.ToInt32(this.hidTeacherIdList.Value);
        clist.courseID = Convert.ToInt32(this.hidcourseIdList.Value);
        clist.VCL_startDate = Convert.ToDateTime(this.txtbeginDate.Text);
        clist.VCL_EndDate = Convert.ToDateTime(this.txtEndData.Text);
        clist.VCL_startTime = Convert.ToDateTime(this.txtbeginTime.Text);
        clist.VCL_EndTime = Convert.ToDateTime(this.txtEndTime.Text);
        clm.UpdateCourseList(clist);
        PageHelper.AlterMsgAndRedirect("修改成功", "SearchCourseAllList.aspx");
    }

    private void showCouerlist()
    {
        int id =Convert.ToInt32(Request.QueryString["id"]);
        int schoolid = this.CurrentUser.SchoolID;
        V_courselist clist = new V_courselist();
        DataSet ds = clm.QueryAllCourseListById(id, schoolid);
        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow dr = ds.Tables[0].Rows[0];
            this.hidTraninClass.Value = dr["trainClassid"].ToString();
            this.hidTeacherIdList.Value = dr["teacherID"].ToString();
            this.hidCoursewareIdList.Value = dr["RoomID"].ToString();
            this.hidcourseIdList.Value = dr["courseID"].ToString();
            this.txtTraninClass.Text = dr["vtc_name"].ToString();
            this.txtteacherName.Text = dr["VT_realname"].ToString();
            this.txtClassroomName.Text = dr["VR_roomName"].ToString();
            this.txtcourseName.Text = dr["VC_name"].ToString();
            this.txtbeginDate.Text = Convert.ToDateTime(dr["vcl_startDate"].ToString()).ToString("yyyy-MM-dd");
            this.txtEndData.Text = Convert.ToDateTime(dr["vcl_EndDate"].ToString()).ToString("yyyy-MM-dd");
            this.txtbeginTime.Text = Convert.ToDateTime(dr["vcl_startTime"].ToString()).ToString("HH:mm");
            this.txtEndTime.Text = Convert.ToDateTime(dr["vcl_endTime"].ToString()).ToString("HH:mm");
        }
    }
}
